package dk.pun.aot.shared.character;

import java.io.Serializable;

@SuppressWarnings("serial")
public class CharacterId implements Serializable, Comparable<CharacterId> {

	private Long characterKey;
	private String characterName;

	@SuppressWarnings("unused")
	private CharacterId() {}
	
	public CharacterId(Long key, String name) {
		this.characterKey = key;
		this.characterName = name;
	}

	public Long getKey() {
		return this.characterKey;
	}

	public String getName() {
		return this.characterName;
	}
	
	public void setName(String name) {
		this.characterName = name;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CharacterId other = (CharacterId) obj;
		if (characterKey == null) {
			if (other.characterKey != null)
				return false;
		} else if (!characterKey.equals(other.characterKey))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "CharacterId [key=" + characterKey + ", name=" + characterName + "]";
	}

	@Override
	public int compareTo(CharacterId otherCharacterId) {
		int result = this.characterName.compareToIgnoreCase(otherCharacterId.characterName);
		if (result == 0) {
			result = this.characterKey.compareTo(otherCharacterId.characterKey);
		}
		return result;
	}

}
